<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE stylesheet [
	<!ENTITY nbsp '&#160;'>
]>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:output method="xml" />

	<xsl:template match="/grid">

		<table border="0" cellspacing="0" cellpadding="1" id="table_{@id}">

			<thead>
				<!-- Massive Actions -->
        <xsl:if test ="/grid/@massiveActions='True'">
          <tr>
					  <th colspan="{count(header/column)+1}">
						  <xsl:for-each select="massiveActions/action">
							  <button class="actionButton" classRollOver="actionButtonOn" onclick="{current()}; return false;" onmouseover="Common.on(this)" onmouseout="Common.off(this)">
								  <xsl:value-of select="@text"/>
							  </button>
						  </xsl:for-each>
					  </th>
				  </tr>
        </xsl:if>
        
				<!-- Header -->
				<tr>
					<xsl:if test ="/grid/@checkable='True'">
						<th align="center" style="width:20px; padding:0px">
              <xsl:if test ="/grid/@checkall='True'">
                <input name="checkboxall_{/grid/@id}" class="checkbox" type="checkbox" value="{@id}" onclick="CustomGrid_SelectAll('{/grid/@id}', this.checked)" style="cursor:pointer"/>
              </xsl:if>
						</th>
					</xsl:if>
					<xsl:for-each select="header/column">
						<th class="{@ordered}">
              <xsl:choose>
                <xsl:when test="/grid/@orderable='True' and @orderable='True'">
                  <a href="#" onclick="CustomGrid_OrderBy('{/grid/@id}', '{@field}')">
                    <xsl:value-of select="current()"/>
                  </a>
                </xsl:when>
                <xsl:otherwise>
                   <xsl:value-of select="current()"/>
                </xsl:otherwise>
              </xsl:choose>
            </th>
					</xsl:for-each>
				</tr>
			</thead>

			<tbody>
				<xsl:for-each select="row[column]">
					  <tr class="{@class} {@disabled}" onmouseover="CustomGrid_RollOver(this)" onmouseout="CustomGrid_RollOut(this)">
          
						<!-- Columnas -->
						<xsl:if test="/grid/@checkable='True' and @disabled='disabled'">
							<td align="center" style="width:20px; padding:0px">
                <input name="checkbox_{/grid/@id}" disabled="{@disabled}" class="checkbox" type="checkbox" value="{@id}" onclick="CustomGrid_Select('{/grid/@id}', this)" style="cursor:pointer"/>
              </td>
						</xsl:if>
            <xsl:if test="/grid/@checkable='True' and @disabled!='disabled'">
              <td align="center" style="width:20px; padding:0px">
                <input name="checkbox_{/grid/@id}" class="checkbox" type="checkbox" value="{@id}" onclick="CustomGrid_Select('{/grid/@id}', this)" style="cursor:pointer"/>
              </td>
            </xsl:if>
            <xsl:for-each select="column">
							<td class="{@class}">
                <xsl:choose>
                    <xsl:when test="@image='True'">
                      <xsl:if test="current()!='noimage'">
                        <img src="{current()}"/>
                      </xsl:if>                        
                    </xsl:when>
                    <xsl:otherwise>
								      <xsl:value-of select="current()" disable-output-escaping="yes"/>
                    </xsl:otherwise>
                </xsl:choose>
							</td>
						</xsl:for-each>

						<!-- Acciones -->
						<xsl:if test="count(action)>0">
							<td width="10px" nowrap="true" align="center" style="padding: 0px;">
								<table>
									<tr>
										<xsl:for-each select="action">
											<td style="border: 0px; cursor:pointer">
												<img src="{@image}" alt="{@text}" title="{@text}" onclick="{current()};return false;"/>
											</td>
										</xsl:for-each>
									</tr>
								</table>
							</td>
						</xsl:if>

					</tr>
				</xsl:for-each>
			</tbody>

		</table>

		<script type="text/javascript">
			CustomGrid_FixHeader("table_<xsl:value-of select="@id"/>");
		</script>
    
  </xsl:template>

</xsl:stylesheet>